<%@ page language="java" contentType="text/html; charset=UTF-8"  import="java.util.*,com.vallis.model.*" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	pageContext.setAttribute("path", request.getContextPath());
	String path = request.getContextPath(); 
	 String basePath = request.getScheme() + "://"  
            + request.getServerName() + ":" + request.getServerPort()  
            + path + "/";  
	
%>
<% Customer user=(Customer)session.getAttribute("User");
 if(user==null){ response.sendRedirect("login.jsp"); 
}%>
<!DOCTYPE HTML>
<html>
  <head>
       <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <meta name="viewport"
        content="width=device-width, initial-scale=1">
    <title>我的代理</title>
   <!-- Set render engine for 360 browser -->
  <meta name="renderer" content="webkit">

  <!-- No Baidu Siteapp-->
  <meta http-equiv="Cache-Control" content="no-siteapp"/>

  <link rel="icon" type="image/png" href="assets/i/favicon.png">

  <!-- Add to homescreen for Chrome on Android -->
  <meta name="mobile-web-app-capable" content="yes">
  <link rel="icon" sizes="192x192" href="assets/i/app-icon72x72@2x.png">

  <!-- Add to homescreen for Safari on iOS -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
  <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">

  <!-- Tile icon for Win8 (144x144 + tile color) -->
  <meta name="msapplication-TileImage" content="assets/i/app-icon72x72@2x.png">
  <meta name="msapplication-TileColor" content="#0e90d2">

  <link rel="stylesheet" href="assets/css/amazeui.min.css">
  <link rel="stylesheet" href="assets/css/app.css">
  <script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"60499",secure:"60202"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></head>
  <body  data-genuitec-lp-enabled="false" data-genuitec-file-id="wc1-0" data-genuitec-path="/customer Maven Webapp/src/main/webapp/addCustomer.jsp">
  
  	<script src="js/jquery-1.12.3.min.js" data-genuitec-lp-enabled="false" data-genuitec-file-id="wc1-0" data-genuitec-path="/customer Maven Webapp/src/main/webapp/addCustomer.jsp"></script>
 <script src="http://cdn.amazeui.org/amazeui/2.7.2/js/amazeui.js"></script>
 <script src="http://cdn.amazeui.org/amazeui/2.7.2/js/amazeui.min.js"></script>
 <script src="http://cdn.amazeui.org/amazeui/2.7.2/js/amazeui.ie8polyfill.js"></script>
 <script src="http://cdn.amazeui.org/amazeui/2.7.2/js/amazeui.ie8polyfill.min.js"></script>
 <script src="http://cdn.amazeui.org/amazeui/2.7.2/js/amazeui.widgets.helper.js"></script>
 <script src="http://cdn.amazeui.org/amazeui/2.7.2/js/amazeui.widgets.helper.min.js"></script>
   <header data-am-widget="header"
          class="am-header am-header-default am-header-fixed">
      <div class="am-header-left am-header-nav">
          <a href="index" class="">
              <span class="am-header-nav-title">
                首页
              </span>

                <i class="am-header-icon am-icon-home"></i>
          </a>
      </div>

      <h1 class="am-header-title">
          公司
      </h1>

        <nav data-am-widget="menu" class="am-menu  am-menu-dropdown1"  
     data-am-menu-collapse
    
    
    
    > 
    <a href="javascript: void(0)" class="am-menu-toggle">
          <i class="am-menu-toggle-icon am-icon-list"></i>
    </a>


      <!--<ul class="am-menu-nav am-avg-sm-1 am-collapse">
          <li class="am-parent">
            <a href="##" class="" >公司</a>
              <ul class="am-menu-sub am-collapse  am-avg-sm-2 ">
                  <li class="">
                    <a href="##" class="" >公司</a>
                  </li>
                  
                  <li class="am-menu-nav-channel"><a href="##" class="" title="公司">进入栏目 &raquo;</a></li>
              </ul>
          </li>
          <li class="am-parent">
            <a href="##" class="" >人物</a>
              <ul class="am-menu-sub am-collapse  am-avg-sm-3 ">
                  <li class="">
                    <a href="##" class="" >公司</a>
                  </li>
                  
              </ul>
          </li>
          <li class="am-parent">
            <a href="#c3" class="" >趋势</a>
              <ul class="am-menu-sub am-collapse  am-avg-sm-4 ">
                  <li class="">
                    <a href="##" class="" >公司</a>
                  </li>
                 
                  <li class="am-menu-nav-channel"><a href="#c3" class="" title="趋势">泥煤 &raquo;</a></li>
              </ul>
          </li>
          <li class="am-parent">
            <a href="##" class="" >投融资</a>
              <ul class="am-menu-sub am-collapse  am-avg-sm-3 ">
                  <li class="">
                    <a href="##" class="" >公司</a>
                  </li>
                
              </ul>
          </li>
          <li class="">
            <a href="##" class="" >创业公司</a>
          </li>
          
      </ul>-->

  </nav>

  </header>
<form class="am-form">
<fieldset>
 <legend>添加代理</legend>
 <div class="am-form-group">
 <input type="hidden" class="" name="boss" id="boss" value="${boss.id }">
      <label for="doc-ipt-email-1">姓名</label>
      <input type="text" name="name" class="" id="name"  required>
    </div>

    <div class="am-form-group">
      <label for="doc-ipt-email-1">电话</label>
      <input type="number" name="phone"class="js-pattern-number" id="phone" required>
    </div>
    <div class="am-form-group">
      <label for="doc-ipt-email-1">微信</label>
      <input type="text" name="weichat"class="" id="weichat" required>
    </div>
    <div class="am-form-group">
      <label for="doc-ipt-email-1">身份证号</label>
      <input type="text"name="certnumber" class="" id="certnumber" required>
    </div>
    <div class="am-form-group">
      <label for="doc-ipt-email-1">地址</label>
      <input type="text"name="address" class="" id="address" required>
    </div>
      <div class="am-form-group">
      <label for="doc-ipt-email-1">等级</label>
    	<select name="agentlevel"  id="agentlevel">
  		<option value="1">1级</option>
 		 <option value="2" selected>2级</option>
 		 <option value="3">3级</option>
 		 <option value="4">4级</option>
 		 <option value="5" >5级</option>
	</select>
    </div>
    <div class="am-form-group">
      <label for="doc-ipt-email-1">押金金额</label>
      <input type="number" name="cashpledge" class="" id="cashpledge" required>
    </div>
    <div class="am-form-group">
      <label for="doc-ipt-email-1">汇款方式</label>
      	<select name="methodofremittance"  id="methodofremittance">
  		<option value="1">网银转账</option>
 		 <option value="2" selected>微信</option>
 		 <option value="3">支付宝</option>
 		 <option value="4">PayPal</option>
 		 <option value="5">其他</option>
	</select>
    </div>
    <div class="am-form-group">
      <label for="doc-ipt-email-1">上级名称</label>
      <input type="text" name="bossname" class="" id="bossname" value="${boss.name }">
    </div>
    <div class="am-form-group">
      <label for="doc-ipt-email-1">上级微信</label>
      <input type="text" name="bossweichat" class="" id="bossweichat" value="${boss.weichat }">
    </div>
     
</fieldset>
</form>
<p><button type="submit" class="am-btn am-btn-default" onclick="checkdata()">提交</button></p>

<script type="text/javascript">
function serializeForm(a) {// 参数为form标签
	var resultJson = {};// 要传递给后台的对象数据
	var array = a.serializeArray();// 序列化表单内容
	$(array).each(function() {
		resultJson[this.name] = this.value.trim();
	});
}
function isCardNo(card)  
{  
   // 身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X  
   var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;  
   if(reg.test(card) === false) 
   {  
       alert("身份证输入不合法");  
       return  false;  
   }  
   return true;
} 
function isEmpty(obj){
    if(typeof obj == "undefined" || obj == null || obj == ""){
        return true;
    }else{
        return false;
    }
}

function checkdata(){
var prop1=$("#name").val();

var prop2=$("#phone").val();
var prop3=$("#weichat").val();
var prop4=$("#certnumber").val();
var prop5=$("#address").val();
var prop6=$("#agentlevel").val();
var prop7=$("#cashpledge").val();
var prop8=$("#methodofremittance").val();
var prop9=$("#bossname").val();
var prop10=$("#bossweichat").val();
if(isEmpty(prop1)){ alert("请输入姓名")}
if(isEmpty(prop2)){ alert("请输入电话")}
if(isEmpty(prop3)){ alert("请输入微信号")}
if(isEmpty(prop4)){ alert("请输入身份证号")}
if(isEmpty(prop5)){ alert("请输入地址")}
if(isEmpty(prop6)){ alert("请输入登记")}

if(isEmpty(prop7)){ alert("请输入押金金额")}
if(isEmpty(prop8)){ alert("请输入汇款方式")}

if(isEmpty(prop9)){ alert("请输入上级姓名")}
if(isEmpty(prop10)){ alert("请输入上级微信")}


if(
!isEmpty(prop1)&&
!isEmpty(prop2)&&
!isEmpty(prop3)&&
!isEmpty(prop4)&&
isCardNo(prop4)&&
!isEmpty(prop5)&&
!isEmpty(prop6)&&

!isEmpty(prop7)&&
!isEmpty(prop8)&&

!isEmpty(prop9)&&
!isEmpty(prop10)
){
gotoAdd();
}



}
function gotoAdd(){
var form =document.forms[0];


form.action="<%=basePath %>addCustomer";
form.method="post";
form.submit();
}
</script>
<div data-am-widget="navbar" class="am-navbar am-cf am-navbar-default "
      id="">
      <ul class="am-navbar-nav am-cf am-avg-sm-4">
          <li >
            <a href="index" class="">
                  <span class="am-icon-home am-icon-lg"></span>
                <span class="am-navbar-label">首页</span>
            </a>
          </li>
          <li data-am-navbar>
            <a href="news.jsp" class="">
                  <span class="am-icon-search am-icon-lg"></span>
                <span class="am-navbar-label">资讯</span>
            </a>
          </li>
          <li data-am-navbar>
            <a href="about.jsp" class="">
                  <span class="am-icon-wpforms am-icon-lg"></span>
                <span class="am-navbar-label">关于我们</span>
            </a>
          </li>
          <!-- <li >
            <a href="https://github.com/allmobilize/amazeui" class="">
                  <span class="am-icon-github"></span>
                <span class="am-navbar-label">GitHub</span>
            </a>
          </li>
          <li >
            <a href="http://amazeui.org/getting-started" class="">
                  <span class="am-icon-download"></span>
                <span class="am-navbar-label">下载使用</span>
            </a>
          </li>
          <li >
            <a href="https://github.com/allmobilize/amazeui/issues" class="">
                  <span class="am-icon-location-arrow"></span>
                <span class="am-navbar-label">Bug 反馈</span>
            </a>
          </li>-->
      </ul>
  </div>
  </body>
</html>
